package com.dp.mallchat.common.chat.service.strategy.mark;

import com.dp.mallchat.common.common.domain.enums.CommonErrorEnum;
import com.dp.mallchat.common.common.utils.AssertUtil;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @Author: dupeng
 * @CreateTime: 2024-07-29  14:44
 * @Description: 消息标记工厂
 */
public class MarkFactory {

    private static Map<Integer, AbstractMarkHandler> STRATEGY_MAP = new HashMap<>();

    public static void register(Integer type, AbstractMarkHandler handler){
        STRATEGY_MAP.put(type, handler);
    }

    public static AbstractMarkHandler getStrategyOrNull(Integer type){
        AbstractMarkHandler abstractMarkHandler = STRATEGY_MAP.get(type);
        AssertUtil.isNotEmpty(abstractMarkHandler, CommonErrorEnum.PARAM_VALID);
        return abstractMarkHandler;
    }

}
